<template>

  <div class="item-info base-info">
    <div class="sub-btn">
      <div class="add-btn">
        <div v-if="this.dotype=='2'">
          <el-button @click="dosave2">保存信息</el-button>
          <el-button @click="submitbaseinfo">提交</el-button>
        </div>
        <div v-if="this.dotype=='1'">
          <el-button @click="dosave" style="float:right;margin-top:20px;margin-right:50%">保存</el-button>
        </div>
      </div>
    </div>
    <!-- <div class="top_info">
      <div class="base_header">
        <h3>基本信息</h3>
      </div>
    </div> -->
    <div class="left-info">
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属单位层级
        </span>
        <select v-model="detailData.danwei1" :disabled="dotype=='4'||dotype=='3'||(this.dotype=='2'&&!isshowsc)" @change="changedanwei1">
          <option value="undefined" selected style="display:none;">请选择</option>
          <option :value="item.hash.code_id" v-for="item in danwei1Arr" :key="item.id">{{item.hash.code_name}}</option>
        </select>
      </div>
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属单位
        </span>
        <select :disabled="dotype=='4'||dotype=='3'||detailData.danwei1==undefined||detailData.danwei1==''" v-model="detailData.danwei2">
          <option value="undefined" selected style="display:none;">请选择</option>
          <option :value="item.hash.code_id" v-for="item in danwei2Arr" :key="item.id">{{item.hash.code_name}}</option>
        </select>
      </div>
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属区域
        </span>
        <select :disabled="dotype=='4'||dotype=='3'" v-model="detailData.region">
          <option value="undefined" selected style="display:none;">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in regionArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属街镇
        </span>
        <select :disabled="dotype=='4'||dotype=='3'" v-model="detailData.jiedao">
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in jdArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div> -->
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>资产编号
        </span>

        <input type="text" v-model="detailData.zcbh" disabled :class="{xiugai:detailData1.zcbh}">
        <div class="upload-btn" v-if="this.dotype=='1'||isshowsc">
          <b class="code" @click="newhcode">生成编号</b>
        </div>
      </div>
      <!-- <div class="item" v-if="this.dotype!='1'">
        <span>资产编号</span>
        <input type="text" v-model="detailData.hnum" :class="{xiugai: detailData1.hnum}" readonly>
      </div>-->
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>房产地址
        </span>
        <input type="text" v-model="detailData.haddr" :disabled="dotype=='4'||dotype=='3'" :class="{xiugai:detailData1.haddr}"
          v-validate="'required'" name="房产地址"
        >
        <b class="errorMes">{{ errors.first('房产地址') }}</b>
      </div>
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>房产状态
        </span>
        <select
          v-model="detailData.dstatus"
          :class="{xiugai:detailData1.dstatus}"
          :disabled="dotype=='4'||dotype=='3'"
        >
          <option value="undefined" selected style="display:none;">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in hstatusArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>
      <!-- <div class="item" v-if="this.dotype!='1'">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属街镇
        </span>
        <input type="text" v-model="detailData.jiedao">
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>所属单位
        </span>
        <select
          class="min1"
          v-model="detailData.danwei1"
          :disabled="dotype=='4'||dotype=='3'"
          @change="getSelectList('10', 'danwei2Arr',detailData.danwei1);"
        >
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in danwei1Arr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
        <select class="min2" :disabled="dotype=='4'||dotype=='3'" v-model="detailData.danwei2">
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in danwei2Arr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>-->
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>是否有产证
        </span>
        <select v-model="detailData.iscert" :disabled="dotype=='4'||dotype=='3'" @change="checkiscert(detailData.iscert)">
          <option value="undefined" selected style="display:none;">请选择</option>
          <option value="是">是</option>
          <option value="否">否</option>
        </select>
        <div class="upload-btn">
          <test localfiletype="02" tn="certpaper" :imagefile.sync="this.detailData" :isupload="dotype">上传产证</test>
        </div>
      </div>
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>产证编号
        </span>
        <input type="text" v-model="detailData.certnum" :class="{xiugai:detailData1.certnum}" :placeholder="(dotype=='4'||dotype=='3')?'':'请输入'"
          :disabled="detailData.iscert=='否'||dotype=='4'||dotype=='3'"
        >
      </div>
      <!-- onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" -->
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>产证面积(平方米)
        </span>
        <input type="text" tabindex="-1" v-model="detailData.areabuild1" :class="{xiugai:detailData1.areabuild1}"
          oninput="value=value.match(/^\d*(\.?\d{0,2})/g)"
          :placeholder="(dotype=='4'||dotype=='3')?'':'请输入'" :disabled="detailData.iscert=='否'||dotype=='4'||dotype=='3'"
          v-validate="'required|decimal'" name="产证面积"
        >
        <b class="errorMes">{{ errors.first('产证面积') }}</b>
      </div>
      <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>占地面积(平方米)
        </span>
        <input type="text" v-model="detailData.zdmj" :class="{xiugai:detailData1.zdmj}"
          :placeholder="(dotype=='4'||dotype=='3')?'':'请输入'" :disabled="dotype=='4'||dotype=='3'"
          oninput="value=value.match(/^\d*(\.?\d{0,2})/g)"
          v-validate="'required'" name="占地面积"
        >
        <b class="errorMes">{{ errors.first('占地面积') }}</b>
      </div>
      <div class="item">
        <span>权利人</span>
        <input type="text" :disabled="dotype=='4'||dotype=='3'" v-model="detailData.qlr" :class="{xiugai:detailData1.qlr}">
      </div>
      <div class="item">
        <span><i v-if="this.dotype=='1'||this.dotype=='2'">*</i>管理单位</span>
        <input type="text" disabled v-model="detailData.glorg" :class="{xiugai:detailData1.glorg}">
      </div>
      <div class="item">
        <span>物业单位</span>
        <input type="text" :disabled="dotype=='4'||dotype=='3'" v-model="detailData.runorg" :class="{xiugai:detailData1.evalorg}">
      </div>
      <div class="item">
        <span>估值单位</span>
        <input type="text" :disabled="dotype=='4'||dotype=='3'" v-model="detailData.evalorg" :class="{xiugai:detailData1.evalorg}">
      </div>
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>实测面积(平方米)
        </span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.acturearea1"
          :class="{xiugai:detailData1.acturearea1}"
          v-validate="'required|decimal'"
          name="实测面积"
        >
        <b class="errorMes">{{ errors.first('实测面积') }}</b>
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>占地面积(亩)(平方米)
        </span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.areabuild2"
          :class="{xiugai:detailData1.areabuild2}"
          v-validate="'required|decimal'"
          name="占地面积(亩)"
        >
        <b class="errorMes">{{ errors.first('占地面积(亩)') }}</b>
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>房产类型
        </span>
        <select
          v-model="detailData.htype"
          :class="{xiugai:detailData1.htype}"
          :disabled="dotype=='4'||dotype=='3'"
        >
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in htypeArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>房产结构
        </span>
        <select
          v-model="detailData.horg"
          :class="{xiugai:detailData1.horg}"
          :disabled="dotype=='4'||dotype=='3'"
        >
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in horgArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
        <div class="upload-btn">
          <test
            localfiletype="01"
            tn="htypeattach"
            :imagefile.sync="this.detailData"
            :isupload="dotype"
          >上传平面图</test>
        </div>
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>楼层数量
        </span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.hfloor"
          :class="{xiugai:detailData1.hfloor}"
          v-validate="'required|decimal'"
          name="楼层数量"
        >
        <b class="errorMes">{{ errors.first('楼层数量') }}</b>
      </div>-->
      <!-- <div class="item icon">
        <span>建筑年限</span>
        <vue-datepicker-local
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.buildtime"
          format="YYYY-MM"
          style="width:300px;border-color:#ccc;border-top: 2px solid #999;"
          clearable
        ></vue-datepicker-local>
      </div>-->
      <!-- <div class="item" style="margin-top:10px">
        <span>建筑年数</span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="buildyears"
          :class="{xiugai:detailData1.buildyears}"
        >
      </div>-->
    </div>
    <div class="right-info">
      <div class="upload">
        <div class="avatar" style="padding-top:20px">
          <ul>
            <li>
              <test tn="image1" localfiletype="02" :imagefile="this.detailData" :isupload="dotype">房产图片1</test>
            </li>
            <li>
              <test tn="image2" localfiletype="02" :imagefile="this.detailData" :isupload="dotype">房产图片2</test>
            </li>
            <li>
              <test tn="image3" localfiletype="02" :imagefile="this.detailData" :isupload="dotype">房产图片3</test>
            </li>
          </ul>
        </div>
        <div class="desc" style="margin-bottom: 28px;">
          <!-- <span>上传的图片为房产外观图，最多上传3张。图片格式支持是jpg、png。</span> -->
          <span>上传的文件为房产外观图，最多上传3个。文件格式支持是jpg、png、pdf。</span>
        </div>
      </div>

      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>房产状态
        </span>
        <select
          v-model="detailData.hstatus"
          :class="{xiugai:detailData1.hstatus}"
          :disabled="dotype=='4'||dotype=='3'"
        >
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in hstatusArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>-->
      <div class="item">
        <span>资产估值(万元)</span>
        <input type="text" :disabled="dotype=='4'||dotype=='3'" v-model="detailData.evalue1" oninput="value=value.match(/^\d*(\.?\d{0,2})/g)"
          :placeholder="(dotype=='4'||dotype=='3')?'':'请输入'" :class="{xiugai:detailData1.evalue1}"
        >
      </div>
      <!-- <div class="item">
        <span>估值单位</span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.evalorg"
          :class="{xiugai:detailData1.evalorg}"
        >
      </div>-->
      <!-- <div class="item">
        <span>
          <i v-if="this.dotype=='1'||this.dotype=='2'">*</i>权属性质
        </span>
        <select
          v-model="detailData.owntype"
          :class="{xiugai:detailData1.owntype}"
          :disabled="dotype=='4'||dotype=='3'"
        >
          <option value="undefined">请选择</option>
          <option
            :value="item.hash.code_id"
            v-for="item in owntypeArr"
            :key="item.id"
          >{{item.hash.code_name}}</option>
        </select>
      </div>-->
      <div class="item icon">
        <span>基准日期</span>
        <el-date-picker type="date" v-model="detailData.jzdate" :disabled="dotype=='4'||dotype=='3'" :placeholder="(dotype=='4'||dotype=='3')?'':'选择'"
          valueFormat="yyyy-MM-dd" format="yyyy 年 MM 月 dd 日"
        ></el-date-picker>
      </div>
      <div class="item textarea">
        <span>资产备注</span>
        <textarea type="text" v-model="detailData.remark"></textarea>
      </div>
      <!-- <div class="item">
        <span>物业单位</span>
        <input
          type="text"
          :disabled="dotype=='4'||dotype=='3'"
          v-model="detailData.runorg"
          :class="{xiugai:detailData1.runorg}"
        >
      </div>-->
    </div>
    <div class="base_header">
      <h3>统计信息</h3>
    </div>
    <div class="left-info">
      <div class="item spec clearfix">
        <span>经营性资产面积
          <br>(平方米)
        </span>
        <div class="text">
          <input type="text" value="有证" readonly>
          <input type="text" v-model="detailData.rentarea1" readonly>
        </div>
        <div class="text">
          <input type="text" value="无证" readonly>
          <input type="text" v-model="detailData.rentarea2" readonly>
        </div>
      </div>
      <div class="item">
        <span>总体无证面积
          <br>(平方米)
        </span>
        <input type="text" style="margin-top:10px" v-model="zongti" readonly>
      </div>
    </div>
    <div class="right-info">
      <div class="item spec clearfix">
        <span>非经营性资产面积
          <br>(平方米)
        </span>
        <div class="text">
          <input type="text" value="有证" readonly>
          <input type="text" v-model="detailData.unrentarea1" readonly>
        </div>
        <div class="text">
          <input type="text" value="无证" readonly>
          <input type="text" v-model="detailData.unrentarea2" readonly>
        </div>
      </div>
      <div class="item">
        <span>总体有证面积
          <br>(平方米)
        </span>
        <input type="text" style="margin-top:10px" v-model="zongti2" readonly>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import test from '~/components/common/upload/test.vue';
import VueDatepickerLocal from 'vue-datepicker-local';

export default {
  data() {
    return {
      ts: this.newStore(),
      detailData: {
        iscert: '否',
        certnum: '无',
        areabuild1: '0',
        zcbh: '',
        rentarea1: '0',
        rentarea2: '0',
        unrentarea1: '0',
        unrentarea2: '0',
      },
      detailData1: {},
      dialogImageUrl: '',
      dialogVisible: false,
      isshowsc: false,
      htypeArr: [],
      horgArr: [],
      hstatusArr: [],
      usetypeArr: [],
      regionArr: [],
      isupload: '',
      owntypeArr: [],
      jdArr: [],
      danwei1Arr: [],
      danwei2Arr: [],
      dotype: '',
    };
  },
  props: {
    handletype: {
      type: String,
      twoWay: true,
    },
    // 点击节点回调
    func: {
      type: Function,
      default: null,
    },
  },
  computed: {
    buildyears() {
      const nowDate = new Date();
      const nowDateyear = nowDate.getFullYear();
      const buildDate = new Date(this.detailData.buildtime);
      const a = buildDate.getFullYear();
      let years;
      if (a) {
        years = nowDateyear - a;
      } else {
        years = 0;
      }
      return years;
    },
    zongti() {
      let zongti1;
      if (this.detailData.rentarea2 && this.detailData.unrentarea2) {
        zongti1 = Number(this.detailData.rentarea2) + Number(this.detailData.unrentarea2);
      } else {
        return 0;
      }
      return zongti1.toFixed(2);
    },
    zongti2() {
      let zongti2;
      if (this.detailData.rentarea1 && this.detailData.unrentarea1) {
        zongti2 = Number(this.detailData.rentarea1) + Number(this.detailData.unrentarea1);
      } else {
        return 0;
      }
      return zongti2.toFixed(2);
    },
  },
  created() {
    console.log(this.detailData.jiedao);
    this.detailData.glorg = localStorage.getItem('orgname');
    this.getSelectList('01', 'htypeArr');
    this.getSelectList('02', 'horgArr');
    this.getSelectList('15', 'hstatusArr');
    this.getSelectList('04', 'usetypeArr');
    this.getSelectList('13', 'regionArr');
    // this.getSelectList('11', 'jdArr');
    this.getSelectList('06', 'owntypeArr');

    this.getSelectList('10', 'danwei1Arr');
  },
  mounted() {
    this.dotype = this.handletype;
    if (this.dotype != '1') {
      this.getbaseinfo();
    }
  },
  components: {
    test,
    VueDatepickerLocal,
  },
  methods: {
    checkiscert(value) {
      if (value == '否') {
        this.detailData.certnum = '无';
        this.detailData.areabuild1 = '0';
      } else {
        this.detailData.certnum = '';
        this.detailData.areabuild1 = '';
      }
    },
    getSelectList(codetype, td, supid) {
      // this.detailData.zcbh = '';
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD1C1E493C3971E71F',
        token: localStorage.getItem('token'),
        supid,
        codetype,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        // console.log(ts.d.data.operation1);
        this[td] = ts.d.data.operation1;
      });
    },
    getTestinput(imgPath, tn) {
      this[tn] = imgPath;
    },
    newhcode() {
      if (this.detailData.danwei1 == '' || this.detailData.danwei1 == undefined) {
        this.$message({
          type: 'error',
          message: '请先选择单位层级',
        });
        return;
      }
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD970858CF7410BABC73DC9BB465DFE61D',
        token: localStorage.getItem('token'),
        jiedao: localStorage.getItem('dept'),
        danwei1: this.detailData.danwei1,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        // console.log(ts.d.data.operation1);
        this.detailData.zcbh = ts.d.data.operation1[0].hash.zcbh;
        console.log(this.detailData.zcbh);

        this.$message({
          type: 'success',
          message: '资产编号生成成功!',
        });
      });
    },
    changedanwei1() {
      this.getSelectList('10', 'danwei2Arr', this.detailData.danwei1);
    },
    getbaseinfo() {
      // else if(this.dotype == '4') {

      // }
      // alert(this.dotype);
      let req;
      if (this.dotype == '3') {
        req = {
          handle: '76ABA4BE996F68CED6E79E6CF72B4AD04920EC37433E0E2F91BE9BB85CED52D6',
          hid: this.$route.query.hid,
          token: localStorage.getItem('token'),
          xh: this.$route.query.xh,
        };
      } else if (this.dotype == '4') {
        req = {
          handle: '76ABA4BE996F68CE15C917E318C173B269F098E9778AE023CB7683D9B20500C7',
          hid: this.$route.query.hid,
          token: localStorage.getItem('token'),
          xh: this.$route.query.xh,
        };
      } else {
        req = {
          handle: '76ABA4BE996F68CE15C917E318C173B275852EAA595983BF',
          hid: this.$route.query.hid,
          token: localStorage.getItem('token'),
          xh: this.$route.query.xh,
        };
      }
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        if (this.dotype == '3') {
          this.detailData = ts.d.data.operation2[0].hash;
          if (this.detailData.danwei1 != '') {
            this.getSelectList(
              '10',
              'danwei2Arr',
              this.detailData.danwei1,
            );
          }
          this.detailData.orgname = this.detailData.glorg;

          if (ts.d.data.operation1.length == 0) {
            this.detailData1 = ts.d.data.operation1[0].hash;
          }
        } else {
          this.detailData = ts.d.data.operation1[0].hash;
          if (this.dotype == '2' && this.detailData.zcbh == '') {
            this.isshowsc = true;
          } else {
            this.isshowsc = false;
          }
          this.getSelectList(
            '10',
            'danwei2Arr',
            this.detailData.danwei1,
          );


          this.detailData1 = ts.d.data.operation1[0].hash;
        }
        if (!this.detailData1.hnum) {
          this.detailData1 = Object.assign({}, this.detailData);
        }
        for (const key in this.detailData1) {
          if (this.detailData1[key] == this.detailData[key]) {
            this.detailData1[key] = false;
          } else {
            this.detailData1[key] = true;
          }
        }
      });
    },

    savebaseinfo(status) {
      let res;
      if (this.detailData.hid) {
        res = {
          handle: '76ABA4BE996F68CEDFC8492E914AB35B4498E195D4BF4051',
          token: localStorage.getItem('token'),
          hid: this.$route.query.hid,
          hnum: this.detailData.hnum,
          haddr: this.detailData.haddr,
          region: this.detailData.region,
          remark: this.detailData.remark,
          dstatus: this.detailData.dstatus,
          // jiedao: this.detailData.jiedao,
          danwei1: this.detailData.danwei1,
          danwei2: this.detailData.danwei2,
          iscert: this.detailData.iscert,
          certnum: this.detailData.certnum,
          htype: this.detailData.htype,
          horg: this.detailData.horg,
          hfloor: this.detailData.hfloor,
          areabuild1: this.detailData.areabuild1,
          areabuild2: this.detailData.areabuild2,
          buildtime: this.detailData.buildtime,
          buildyears: this.detailData.buildyears,
          hstatus: this.detailData.hstatus,
          evalue1: this.detailData.evalue1,
          evalorg: this.detailData.evalorg,
          zdmj: this.detailData.zdmj,

          zcbh: this.detailData.zcbh,
          qlr: this.detailData.qlr,
          glorg: this.detailData.glorg,
          jzdate: this.detailData.jzdate,

          acturearea1: this.detailData.acturearea1,
          owntype: this.detailData.owntype,
          runorg: this.detailData.runorg,
          certpaper: this.detailData.certpaper,
          htypeattach: this.detailData.htypeattach,
          image1: this.detailData.image1,
          image2: this.detailData.image2,
          image3: this.detailData.image3,
          checkstatus: status,
        };
      } else {
        res = {
          handle: '76ABA4BE996F68CE5F203644521BEE2AF29949653ADD16DF',
          token: localStorage.getItem('token'),
          hid: this.$route.query.hid,
          hnum: this.detailData.hnum,
          haddr: this.detailData.haddr,
          region: this.detailData.region,
          remark: this.detailData.remark,
          // jiedao: this.detailData.jiedao,
          dstatus: this.detailData.dstatus,
          zdmj: this.detailData.zdmj,
          danwei1: this.detailData.danwei1,
          danwei2: this.detailData.danwei2,
          iscert: this.detailData.iscert,
          certnum: this.detailData.certnum,
          htype: this.detailData.htype,
          horg: this.detailData.horg,
          hfloor: this.detailData.hfloor,
          areabuild1: this.detailData.areabuild1,
          areabuild2: this.detailData.areabuild2,
          buildtime: this.detailData.buildtime,
          buildyears: this.detailData.buildyears,
          hstatus: this.detailData.hstatus,
          evalue1: this.detailData.evalue1,
          evalorg: this.detailData.evalorg,
          zcbh: this.detailData.zcbh,
          qlr: this.detailData.qlr,
          glorg: this.detailData.glorg,
          jzdate: this.detailData.jzdate,
          acturearea1: this.detailData.acturearea1,
          owntype: this.detailData.owntype,
          runorg: this.detailData.runorg,
          certpaper: this.detailData.certpaper,
          htypeattach: this.detailData.htypeattach,
          image1: this.detailData.image1,
          image2: this.detailData.image2,
          image3: this.detailData.image3,
          checkstatus: status,
        };
      }
      return new Promise((resolve) => {
        this.spost(this.ts, '/mainservlet', res).then((ts) => {
          // console.log(ts.d);
          resolve(ts.d);
        });
      });
    },
    dosave() {
      if (this.detailData.zcbh == '') {
        this.$message('资产编号不能为空');
        return;
      }

      const req = {
        handle: '76ABA4BE996F68CE417AAAFED0C1AC07F5E63AAF59B4F74B599523DE7304A66C',
        token: localStorage.getItem('token'),
        zcbh: this.detailData.zcbh,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        if (ts.d.data.operation1[0].hash.cou == '0') {
          if (!this.detailData.haddr) {
            this.$message('房产地址不能为空');
          } else if (!this.detailData.iscert) {
            this.$message('请选择是否有产证');
          } else if (!this.detailData.areabuild1) {
            this.$message('产证面积不能为空');
          } else if (!this.detailData.zdmj) {
            this.$message('占地面积不能为空');
          } else {
            this.$confirm('确认保存？', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning',
            })
              .then(() => {
                this.savebaseinfo('0').then((ts) => {
                  this.$message({
                    type: 'success',
                    message: '保存成功!',
                  });
                  if (this.detailData.hid) {
                    this.$router.push({
                      name: 'detailInfo',
                      query: {
                        hid: this.detailData.hid,
                      },
                    });
                  } else {
                    this.$router.push({
                      name: 'detailInfo',
                      query: {
                        hid: ts.data.operation4[0].hash.hid,
                        xh: ts.data.operation4[0].hash.xh,
                      },
                    });
                  }
                });
              })
              .catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消',
                });
              });
          }
        } else {
          this.$message({
            type: 'error',
            message: '资产编号已存在，请重新生成后再提交！',
          });
        }
      });
    },
    dosave2() {
      if (this.detailData.zcbh == '') {
        this.$message('资产编号不能为空');
        return;
      }
      if (!this.detailData.haddr) {
        this.$message('房产地址不能为空');
      } else if (!this.detailData.iscert) {
        this.$message('请选择是否有产证');
      } else if (!this.detailData.areabuild1) {
        this.$message('产证面积不能为空');
      } else {
        this.$confirm('确认保存？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            this.savebaseinfo('0').then(() => {
              this.$message({
                type: 'success',
                message: '保存成功!',
              });
              this.getbaseinfo();
            });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            });
          });
      }
    },
    // else if (this.detailData.areabuild1 <= this.detailData.rentarea1) {
    //   this.$message('产证面积不能小于有证面积');
    // }

    submitbaseinfo() {
      console.log(this.detailData.dstatus);

      if (this.detailData.region == '') {
        this.$message('所属区域不能为空');
        return;
      }
      if (this.detailData.hnum == '') {
        this.$message('资产编号不能为空');
        return;
      }
      if (this.detailData.haddr == '') {
        this.$message('房产地址不能为空');
        return;
      }
      if (this.detailData.dstatus == '') {
        this.$message('请选择房产状态');
        return;
      }
      if (this.detailData.danwei1 == '') {
        this.$message('所属单位不能为空');
        return;
      }
      if (this.detailData.danwei2 == '') {
        this.$message('所属单位不能为空');
        return;
      }
      if (this.detailData.zdmj == '') {
        this.$message('占地面积不能为空');
        return;
      }
      if (this.detailData.iscert == '') {
        this.$message('是否有产证不能为空');
        return;
      }
      if (
        this.detailData.certnum == '' &&
						this.detailData.iscert == '是'
      ) {
        this.$message('产证编号不能为空');
        return;
      }
      if (!this.detailData.areabuild1) {
        this.$message('产证面积不能为空');
        return;
      }
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD89D98CC08EF55FA1C328C875E62DAA9981A8A21A78B4FDCC',
        token: localStorage.getItem('token'),
        hid: this.$route.query.hid,
        zdmj: this.detailData.zdmj,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        if (Number(ts.d.data.operation1[0].hash.cou) > 0) {
          this.$alert('未分配面积不为0，全部分配后才可提交房产', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }


        if (Number(this.detailData.areabuild1) < Number(this.detailData.rentarea1) + Number(this.detailData.unrentarea1)) {
          this.$alert('产证面积小于经营性有证面积和非经营性有证面积', '提示', {
            confirmButtonText: '确定',
            callback: () => {
              this.$confirm('提交后不可修改，确认提交？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
              }).then(() => {
                this.savebaseinfo('1').then((tt) => {
                  this.$message({
                    type: 'success',
                    message: '提交成功!',
                  });
                  this.$router.push({
                    name: 'houseManage',
                    query: {
                      funcid: '204000',
                    },
                  });
                });
              }).catch(() => {});
            },
          });
        } else {
          this.$confirm('提交后不可修改，确认提交？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(() => {
            this.savebaseinfo('1').then((tt) => {
              this.$message({
                type: 'success',
                message: '提交成功!',
              });
              this.$router.push({
                name: 'houseManage',
                query: {
                  funcid: '204000',
                },
              });
            });
          }).catch(() => {});
        }
      });
    },
  },
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
	.code {
		padding: 7px 3px;
		height: 33px;
		line-height: 33px;
		position: relative;
		background: #69f;
		border-radius: 3px;
		text-decoration: none;
		color: #fff;
	}

	.errorMes {
		width: 160px;
		color: red;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		display: inline-block;
	}

	.weixiugai {
		background: #69f;
	}

	.item {
		i {
			color: red;
		}
	}

	.base_header {
		padding: 10px;
		border-bottom: 1px solid #ccc;
		font-size: 18px;
		color: #69f;
	}

	.xiugai {
		background: #ffff0070;
	}

	.avatar ul li {
		float: left;
		width: 33%;
	}

	.info-wrapper .info-content .upload-btn[data-v-6b40dfc5] {
		background: #fff;
		width: 90px;
	}

	.item-info>>>.el-date-editor .el-range-separator {
		padding: 0;
		line-height: 22px;
	}

	.item-info>>>.el-date-editor.el-input,
	.el-date-editor.el-input__inner {
		width: 300px;
		height: 30px;
	}

	.item-info>>>.el-input__inner {
		height: 30px;
		border-top: 2px solid #999;
		border-radius: 0;
	}

	.item-info>>>.el-input__icon {
		line-height: 22px;
		color: #333;
	}

	.avatar>>>.el-upload--picture-card {
		width: 90px;
		height: 90px;
		line-height: 100px;
		margin-top: 20px;
	}

	.avatar>>>.el-upload-list--picture-card .el-upload-list__item {
		width: 90px;
		height: 90px;
		margin-top: 20px;
	}

	.upload-btn>>>.el-upload-list__item {
		width: 160%;
	}

	.sub-btn>>>.el-button--success {
		background: #69f;
		border-color: #69f;
	}

	.sub-btn>>>.el-button {
		padding: 8px 20px;
	}

	.info-wrapper {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;

		.info-w {
			height: 50px;
			line-height: 50px;
			width: 100%;
			background: #69f;
			color: #fff;
			cursor: pointer;

			.info-c {
				width: 1200px;
				margin: 0 auto;

				.close {
					display: inline-block;
					margin-right: 20px;

					.iconfont {
						font-size: 20px;
					}
				}

				.title {
					display: inline-block;
					font-size: 18px;
				}
			}
		}

		.info-content {
			width: 1200px;
			min-height: 600px;
			margin: 0 auto 50px;

			.upload-btn {
				display: inline-block;
				vertical-align: top;
				margin-left: 5px;
				width: 80px;
				height: 30px;
				line-height: 30px;
				text-align: center;
				border-radius: 5px;
				color: #fff;
			}

			.info-tab {
				cursor: pointer;
				border-bottom: 1px solid #ccc;

				.tab-item {
					display: inline-block;
					width: 120px;
					height: 40px;
					line-height: 40px;
					text-align: center;
					border: 1px solid #ccc;
					margin: 15px 0 15px -1px;
					background: #fff;

					&.active {
						background: #69f;
						color: #fff;
					}
				}
			}

			.item-info {
				position: relative;
				margin-bottom: 50px;

				.sub-btn {
					position: absolute;
					right: 190px;
					top: -60px;
					height: 40px;
					line-height: 40px;

					.save-btn,
					.add-btn {
						display: inline-block;
						margin-right: 15px;
					}
				}

				.info-list {
					margin-top: 50px;
					border-top: 1px solid #ccc;
					text-align: center;

					.title {
						padding: 30px 0;
						font-weight: 600;
						font-size: 18px;
						color: #6699ff;
					}

					table {
						text-align: center;
						padding-left: 30px;
						cursor: pointer;
						border-collapse: collapse;

						td,
						th {
							border: 1px solid #ccc;
							font-size: 14px;
							color: #666;
							height: 40px;
						}

						thead {
							th {
								font-weight: 600;
								background-color: #F2F2F2;

								&:nth-of-type(1) {
									width: 40px;
								}

								&:nth-of-type(2) {
									width: 120px;
								}
							}
						}
					}
				}

				.left-info,
				.right-info {
					display: inline-block;
					vertical-align: top;
					width: 600px;

					.item {
						margin-top: 5px;
						height: 30px;
						line-height: 30px;

						&:nth-of-type(1) {
							margin-top: 15px;
						}

						&.icon {
							position: relative;

							.iconfont {
								position: absolute;
								top: 0;
								right: 190px;
							}
						}

						span {
							display: inline-block;
							vertical-align: top;
							width: 140px;
							color: #333333;
							font-weight: 600;
						}

						input {
							display: inline-block;
							vertical-align: top;
							width: 300px;
							height: 30px;
							border: 1px solid #ccc;
							border-top: 2px solid #999;
						}

						select {
							display: inline-block;
							width: 300px;
							height: 30px;
							border: 1px solid #ccc;
							border-top: 2px solid #999;
							text-align: right;

							&.min1 {
								width: 100px;
							}

							&.min2 {
								width: 200px;
								margin-left: -1px;
							}
						}

						&.textarea {
							height: 150px;

							textarea {
								width: 300px;
								height: 135px;
								border: 1px solid #ccc;
								border-top: 2px solid #999;
							}
						}

						&.spec {
							height: 70px;

							span {
								float: left;
							}

							.text {
								display: inline-block;

								input:nth-of-type(1) {
									width: 100px;
								}

								input:nth-of-type(2) {
									width: 200px;
								}

								&:nth-of-type(2) {
									margin-top: 5px;
								}
							}
						}

						&.spec2 {
							height: 30px;

							.text {
								display: inline-block;

								input {
									display: inline-block;
									vertical-align: top;
								}

								input:nth-of-type(1) {
									width: 200px;
								}

								input:nth-of-type(2) {
									width: 100px;
								}

								select {
									display: inline-block;
									vertical-align: top;
									width: 100px;
								}
							}
						}

						&.spec3 {
							height: 70px;

							span {
								height: 70px;
								float: left;
							}

							.text {
								display: inline-block;
								margin-top: 5px;

								input:nth-of-type(1) {
									width: 200px;
								}

								input:nth-of-type(2) {
									width: 100px;
								}
							}
						}

						&.spec4 {
							height: 70px;

							span {
								float: left;
								height: 70px;
							}

							input {
								margin-top: 5px;
							}
						}

						&.spec5 {
							.line {
								display: inline-block;
								vertical-align: middle;
								width: 20px;
								height: 1px;
								background: #ccc;
							}

							.iconfont {
								&:ntn-of-type(1) {
									right: 190px;
								}

								&:nth-of-type(2) {
									right: 350px;
								}
							}
						}
					}

					.upload {
						width: 400px;
						margin-top: 15px;
						text-align: center;

						.avatar {
							width: 400px;
							height: 175px;
							border: 1px solid #ccc;
							margin-bottom: 15px;
						}

						.desc {
							margin-bottom: 15px;
						}

						.btn {
							display: inline-block;
							margin-bottom: 15px;
							width: 80px;
							height: 30px;
							line-height: 30px;
							text-align: center;
							border-radius: 5px;
							background: #69f;
							color: #fff;
						}
					}
				}

				&.base-info {
					.right-info {
						.item {
							margin-top: 6px;
						}
					}
				}

				&.rent-info {
					.right-info {
						.item {
							margin-top: 11px;

							&:nth-of-type(1) {
								margin-top: 15px;
							}
						}
					}
				}

				span {
					display: inline-block;
					vertical-align: top;
				}
			}
		}
	}
</style>
